This invention relates to a filter and method for filtering pixels of a frame in a graphical processing system, and in particular for filtering pixels in a frame rendered by path or ray tracing.
Several techniques are available for rendering three-dimensional (3D) scenes for display on a computer system. These include scanline rendering into two dimensions of a scene described in the computer system in three dimensions, path tracing and ray tracing. Path tracing forms an image by determining the net colour arriving at each pixel of a frame defined at a particular viewpoint in a 3D scene. The net colour is calculated by integrating over the contributions from all of the light rays received at the pixel, including light rays which have been reflected (potentially multiple times) by surfaces in the scene. By defining physically accurate models of the surfaces and light sources in the scene, including the reflection characteristics of the surfaces, very realistic images can be rendered. Ray tracing forms an image in a similar manner but typically for each point in the scene which contributes to the rendered image, the colour of that point is determined only from the light received at that point from the light sources in the scene (i.e. direct light only). Many variations of path and ray tracing are possible, including hybrid techniques which use path or ray tracing to determine the lighting to be applied to a conventional texture-mapped 3D scene.
In order to substantially reduce the number of calculations required to render an image using path or ray tracing techniques, light rays are typically traced backwards from the viewpoint to a light source. This avoids the overhead of performing calculations in respect of light rays which would not be seen at the viewpoint from which the output image is captured. The number of rays traced through the scene for each pixel in the output image is generally referred to as the number of samples per pixel, or SPP.
An illustration of a frame 112 being rendered by path tracing is shown in FIG. 1, which is a plan view of a 3D scene 100. In the scene, a nominal camera 101 is looking down a corridor 102 that includes a window 106 through which light enters from a light source—in this case, sun 103. The viewpoint of the camera is to be rendered as frame 112, with each pixel of the frame being determined by the totality of the light rays passing through that pixel. The corridor additionally includes columns 104 along wall 117 and a picture 105 on wall 118.
The scene could be a 3D scene defined in a computer game, with camera 101 representing the protagonist from whose point of view the game is played. In this example, the scene is defined at a computer system by a 3D model (e.g. a set of polygons defining the scene geometry) and texture information which can be applied to the 3D model. The 3D model defines the position and contour of the surfaces in the scene, and each texture defines the characteristics of the surface to which it is applied. For example, a texture will typically characterise the appearance of a surface in terms of its colours and patterning, and may also determine other properties such as its reflectivity, and the degree to which reflections from the surface are specular or diffuse.
Three exemplary light rays 108-110 are shown in FIG. 1, each of which originates from the source of light coming through window 106 and reflect off one or more surfaces of the scene before reaching the camera 101. Each of light rays 108-110 are identified however by tracing rays backwards from the camera 101 through pixels of the frame 112 at which an image of the scene is to be formed. Light ray 108 passes through pixel 114 and reflects off picture 105 whose paint imparts a colour to the ray, and causes diffuse reflection 127. Light ray 108 next encounters wall 117 which has a low reflectivity (leading to loss of brightness), a grey colour and causes diffuse reflection 128. The diffuse nature of reflections 127 and 128 can be modelled by picking the angle of reflections 121 and 122 at random (typically according to a Lambert's cosine law). In the case of reflection 128 this causes the light ray to be directed out of window 106. By considering the amount of light propagated along the path from the light source to the camera, the contribution from light ray 108 at pixel 114 can be determined: the substantially white light of a given intensity coming through window 106 becomes a dull grey as a result of reflection 128 and is then reflected by picture 105 with a colour change.
Light rays 109 and 110 each undergo a single reflection. Light ray 109 is traced back through pixel 115 to meet column 104 which is a polished pink marble that is of relatively high reflectivity, imparts a pink colour to the ray, and causes reflection 125. In contrast, light ray 110 is traced back through pixel 116 to meet wall 117 and hence is largely absorbed, imparted with a grey colour and undergoes a diffuse reflection. By reversing the paths of rays 109 and 110 and applying the properties of reflections 125 and 126 to the light rays entering through window 106, the contributions of those rays to pixels 115 and 116 can be determined. Typically light rays would be traced back from the camera only up to some predefined number of reflections; if a light source is not encountered within that number of reflections, the ray can be discarded.
By repeating the path tracing process for multiple rays through a pixel, each ray having a slightly different (possibly randomly-chosen) orientation through the pixel, a colour for the pixel can be established by averaging the results from all samples (e.g. according to Monte Carlo integration). By performing this process for each pixel of frame 112, the complete frame can be generated. Generated in this manner, the frame includes lighting information which results from the scene geometry, the location and characteristics of the light sources in the scene, as well as the texture information and surface characteristics for the surfaces present in the scene.
When only a relatively small number of light rays contribute to each pixel and the samples per pixel (SPP) is low, the level of noise in the rendered frame can be high. Increasing the number of samples per pixel increases the accuracy of the rendered frame and causes the level of noise in the frame to drop. However, increasing the number of samples per pixel significantly increases the time required to render the frame.